﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.iss.inventory.Controllers;
using System.Drawing;

namespace Staionery_Inventory.Presentation.StockCard
{
    public partial class ViewAdjVoucherUI__Reload_ : System.Web.UI.Page
    {
        ViewAdjVoucherController viewCon = new ViewAdjVoucherController();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["empID"] == null)
            {
                Response.Redirect("~/Presentation/login.aspx");
            }
            Label lbl = this.Master.FindControl("lblLogInName") as Label;
            if (lbl != null)
            {
                lbl.Text = Session["UserName"].ToString();
            }


            lblForAdjustID.Visible = false; lblForDateAdj.Visible = false;
            lblMessage.Text = "Please enter in a voucher no";
            gvAdjVoucher.DataSource = null;
            gvAdjVoucher.DataBind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtAdjustID.Text != "")
            {
                lblAdjustID.Text = txtAdjustID.Text; 
                String date = viewCon.getDateByAdjustID(txtAdjustID.Text);
                if (date == null)
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text = "Please enter a correct Voucher No";
                    lblAdjustID.Text = ""; lblDateAdj.Text = "";
                    lblForAdjustID.Visible = false; lblForDateAdj.Visible = false;
                }
                else
                {
                    lblMessage.ForeColor = Color.Black;
                    lblMessage.Text = "Load Successfully";
                    gvAdjVoucher.DataSource = viewCon.getVoucherByAdjustID(txtAdjustID.Text);
                    gvAdjVoucher.DataBind();
                    lblAdjustID.Text = txtAdjustID.Text; txtAdjustID.Text = "";

                    lblForAdjustID.Visible = true; lblForDateAdj.Visible = true;
                    lblDateAdj.Text = date;
                }
            }
            else {
                txtAdjustID.Text = "";
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text = "Please enter in a voucher no";
            }

        }
    }
}